package com.fly;

import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.RandomUtils;

import com.fly.core.MyJdbcTemplate;

import lombok.extern.slf4j.Slf4j;

public class Main
{
    /**
     * MAIN
     * 
     * @param args
     * @see [类、类#方法、类#成员]
     */
    public static void main(String[] args)
    {
        int i = 0;
        while (i++ < 8)
        {
            new MyThread().start();
        }
    }
}

/**
 * 
 * 单元测试线程
 * 
 * @author 00fly
 * @version [版本号, 2018年9月23日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Slf4j
class MyThread extends Thread
{
    private MyJdbcTemplate myJdbcTemplate = new MyJdbcTemplate();
    
    public MyThread()
    {
        super();
    }
    
    @Override
    public void run()
    {
        try
        {
            myJdbcTemplate.querySql("select id, name, age from user limit 5");
            TimeUnit.SECONDS.sleep(RandomUtils.nextLong(1, 20));
            myJdbcTemplate.querySql("select id, name, age from user limit 5");
        }
        catch (Exception e)
        {
            log.error(e.getMessage(), e);
        }
    }
}
